Return * for n number of times


Posted by Christy on 2022-04-19

Description: Write a function that accepts a number n and returns * for n number of times

function star(n) {

}

console.log(star(3)); // ***
function star(n) {
  let result = "";
  for (let i = 1; i <= n; i++) {
    result += "*";
  }
  return result;
}

console.log(star(3));

Be careful about the way of ouput, if it's print -> console.log; if it's return -> return










Related Posts

【Tips】建立OnPropertyChanged。其中的方法簽章若沒有寫入,則預設為呼叫的成員名稱

【Tips】建立OnPropertyChanged。其中的方法簽章若沒有寫入,則預設為呼叫的成員名稱

Chapter 7 數據責任

Chapter 7 數據責任

如何用 TensorFlow object detection API 的 Single Shot MultiBox Detector 來做 hand detection

如何用 TensorFlow object detection API 的 Single Shot MultiBox Detector 來做 hand detection


Comments